﻿// ....................................................................................................................
//	Author: Copyright (C) 2012 Ing. Marek Hubal
//	Email: hubal@acasoftware.org
// ....................................................................................................................

using System;

namespace core
{
    /// <summary>Trieda INode</summary>
    public class INode : IDisposable
    {
        public const int NODE_ID_NONE = 0;
        public const int NODE_ID_LOCAL_DRIVE = 1;
        public const int NODE_ID_LOCAL_ITEM = 2;
        public const int NODE_ID_BACK_ITEM = 3;
        public const int NODE_ID_SMB_ROOT = 4;
        public const int NODE_ID_SMB_COMPUTER = 5;
        public const int NODE_ID_SMB_SHARE = 6;
        public const int NODE_ID_GZIP_ITEM = 7;
        public const int NODE_ID_TAR_ITEM = 8;
        public const int NODE_ID_RAR_ITEM = 9;
        public const int NODE_ID_CLOUD_DEVICES = 10;
        public const int NODE_ID_FTP_CONNECTION = 11;
        public const int NODE_ID_FTP_ITEM = 12;
        public const int NODE_ID_ZIP_ITEM = 13;
        public const int NODE_ID_VIRTUAL_ITEM = 14;

        public int ID; // ID node
        public string[] DisplayStrings;
        public int DefaultImageIndex;
        public int ImageIndex;
        public bool Selected;
        public string RelativeName;
        public int ConnectionProvider;

        public object NodeData; // Data

        public bool ValidSize;
        protected string FNameOnly;
        protected string FExt;
        protected long FSize;

        /// <summary>Konstruktor</summary>
        public INode()
        {
            ID = NODE_ID_NONE;
            DisplayStrings = null;
            DefaultImageIndex = -1;
            ImageIndex = -1;
            ValidSize = false;
            FSize = -1;
            //FDCreate = DateTime.MinValue;
            //FDLastModify = DateTime.MinValue;
            //FDLastAccess = DateTime.MinValue;
            Selected = false;
            ConnectionProvider = 0;
        }
        /// <summary>Dispose metoda</summary>
        public void Dispose()
        {
            DisplayStrings = null;
            NodeData = null;
        }
        /// <summary>Vymazanie obsahu</summary>
        public void Clear()
        {
            ValidSize = false;
            FNameOnly = "";
            FExt = "";
            FSize = -1;
            //FDCreate = DateTime.MinValue;
            //FDLastModify = DateTime.MinValue;
            //FDLastAccess = DateTime.MinValue;
        }

        /// <summary>Property: IsDirectory</summary>
        public bool IsDirectory
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM: return (((INodeData_VIRTUAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) != 0;
                    case NODE_ID_ZIP_ITEM: return (((INodeData_ZIP)NodeData).ZIP_Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) != 0;
                    case NODE_ID_RAR_ITEM: return (((INodeData_RAR_ITEM)NodeData).RAR_Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) != 0;
                    case NODE_ID_TAR_ITEM: return ((INodeData_TAR_ITEM)NodeData).TAR_IsDirectory;
                    case NODE_ID_FTP_ITEM: return ((INodeData_FTP_ITEM)NodeData).FTP_IsDirectory;
                    case NODE_ID_LOCAL_ITEM:
                        {
                            return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) != 0;
                        }
                    default: return false;
                }
            }
        }
        /// <summary>Property: IsFile</summary>
        public bool IsFile
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM: return (((INodeData_VIRTUAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) == 0;
                    case NODE_ID_ZIP_ITEM: return (((INodeData_ZIP)NodeData).ZIP_Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) == 0;
                    case NODE_ID_RAR_ITEM: return (((INodeData_RAR_ITEM)NodeData).RAR_Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) == 0;
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_DIRECTORY) == 0;
                    case NODE_ID_FTP_ITEM: return !((INodeData_FTP_ITEM)NodeData).FTP_IsDirectory;
                    case NODE_ID_GZIP_ITEM: return true;
                    case NODE_ID_TAR_ITEM: return !((INodeData_TAR_ITEM)NodeData).TAR_IsDirectory;
                    default: return false;
                }
            }
        }
        /// <summary>Property: Name</summary>
        public string Name
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM: return ((INodeData_VIRTUAL_ITEM)NodeData).Name;
                    case NODE_ID_LOCAL_ITEM: return ((INodeData_LOCAL_ITEM)NodeData).Name;
                    case NODE_ID_LOCAL_DRIVE: return ((INodeData_LOCAL_DRIVE)NodeData).DrvInfo.Name;
                    case NODE_ID_GZIP_ITEM: return ((INodeData_GZIP_ITEM)NodeData).GZip_ItemName;
                    case NODE_ID_TAR_ITEM: return ((INodeData_TAR_ITEM)NodeData).TAR_ItemName;
                    case NODE_ID_RAR_ITEM: return ((INodeData_RAR_ITEM)NodeData).RAR_ItemName;
                    case NODE_ID_FTP_ITEM: return ((INodeData_FTP_ITEM)NodeData).FTP_ItemName;
                    case NODE_ID_ZIP_ITEM: return ((INodeData_ZIP)NodeData).ZIP_ItemName;
                    default: return "";
                }
            }
        }
        /// <summary>Property: NameOnly</summary>
        public string NameOnly
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_VIRTUAL_ITEM)NodeData).Name);
                            return FNameOnly;
                        }
                    case NODE_ID_ZIP_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_ZIP)NodeData).ZIP_ItemName);
                            return FNameOnly;
                        }
                    case NODE_ID_FTP_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_FTP_ITEM)NodeData).FTP_ItemName);
                            return FNameOnly;
                        }
                    case NODE_ID_RAR_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_RAR_ITEM)NodeData).RAR_ItemName);
                            return FNameOnly;
                        }
                    case NODE_ID_TAR_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_TAR_ITEM)NodeData).TAR_ItemName);
                            return FNameOnly;
                        }
                    case NODE_ID_GZIP_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_GZIP_ITEM)NodeData).GZip_ItemName);
                            return FNameOnly;
                        }
                    case NODE_ID_LOCAL_ITEM:
                        {
                            if (string.IsNullOrEmpty(FNameOnly)) FNameOnly = IFileSystem.ExtractNameOnly(((INodeData_LOCAL_ITEM)NodeData).Name);
                            return FNameOnly;
                        }
                    default: return "";
                }
            }
        }
        /// <summary>Property: Ext</summary>
        public string Ext
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_VIRTUAL_ITEM)NodeData).Name);
                            return FExt;
                        }
                    case NODE_ID_LOCAL_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_LOCAL_ITEM)NodeData).Name);
                            return FExt;
                        }
                    case NODE_ID_GZIP_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_GZIP_ITEM)NodeData).GZip_ItemName);
                            return FExt;
                        }
                    case NODE_ID_TAR_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_TAR_ITEM)NodeData).TAR_ItemName);
                            return FExt;
                        }
                    case NODE_ID_RAR_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_RAR_ITEM)NodeData).RAR_ItemName);
                            return FExt;
                        }
                    case NODE_ID_FTP_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_FTP_ITEM)NodeData).FTP_ItemName);
                            return FExt;
                        }
                    case NODE_ID_ZIP_ITEM:
                        {
                            if (string.IsNullOrEmpty(FExt)) FExt = IFileSystem.ExtractExtension(((INodeData_ZIP)NodeData).ZIP_ItemName);
                            return FExt;
                        }
                    default: return "";
                }
            }
        }
        /// <summary>Property: Size</summary>
        public long Size
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM:
                        {
                            if (FSize == -1)
                            {
                                FSize = (long)((INodeData_VIRTUAL_ITEM)NodeData).Size;
                            }
                            return FSize;
                        }
                    case NODE_ID_LOCAL_ITEM:
                        {
                            if (FSize == -1)
                            {
                                FSize = (long)((INodeData_LOCAL_ITEM)NodeData).Size;
                            }
                            return FSize;
                        }
                    case NODE_ID_GZIP_ITEM: return (long)((INodeData_GZIP_ITEM)NodeData).GZip_OriginalSize;
                    case NODE_ID_TAR_ITEM: return (long)((INodeData_TAR_ITEM)NodeData).TAR_OriginalSize;
                    case NODE_ID_RAR_ITEM: return (long)((INodeData_RAR_ITEM)NodeData).RAR_OriginalSize;
                    case NODE_ID_FTP_ITEM: return (long)((INodeData_FTP_ITEM)NodeData).FTP_Size;
                    case NODE_ID_ZIP_ITEM: return (long)((INodeData_ZIP)NodeData).ZIP_OriginalSize;
                    default: return -1;
                }
            }
            set
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM:
                        {
                            FSize = value;
                            ValidSize = true;
                        } break;
                    case NODE_ID_TAR_ITEM:
                        {
                            ((INodeData_TAR_ITEM)NodeData).TAR_OriginalSize = value;
                            ValidSize = true;
                        } break;
                    case NODE_ID_RAR_ITEM:
                        {
                            ((INodeData_RAR_ITEM)NodeData).RAR_OriginalSize = value;
                            ValidSize = true;
                        } break;
                    case NODE_ID_ZIP_ITEM:
                        {
                            ((INodeData_ZIP)NodeData).ZIP_OriginalSize = value;
                            ValidSize = true;
                        } break;
                }
            }
        }
        /// <summary>Property: Attributes</summary>
        public uint Attributes
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM: return ((INodeData_VIRTUAL_ITEM)NodeData).Attributes;
                    case NODE_ID_LOCAL_ITEM: return ((INodeData_LOCAL_ITEM)NodeData).Attributes;
                    case NODE_ID_TAR_ITEM: return ((INodeData_TAR_ITEM)NodeData).TAR_IsDirectory ? IWin32.FILE_ATTRIBUTE_DIRECTORY : IWin32.FILE_ATTRIBUTE_ARCHIVE;
                    case NODE_ID_RAR_ITEM: return ((INodeData_RAR_ITEM)NodeData).RAR_Attributes;
                    case NODE_ID_ZIP_ITEM: return ((INodeData_ZIP)NodeData).ZIP_Attributes;
                    default: return IsDirectory ? IWin32.FILE_ATTRIBUTE_DIRECTORY : IWin32.FILE_ATTRIBUTE_NORMAL;
                }
            }
        }
        /// <summary>Property: AttributesAsString</summary>
        public string AttributesAsString
        {
            get
            {
                return FormatAttributesAsString(Attributes);
            }
        }
        /// <summary>Property: DCreate</summary>
        public DateTime DCreate
        {
            get
            {
                DateTime FDCreate = DateTime.MinValue;
                if (FDCreate == DateTime.MinValue)
                {
                    switch (ID)
                    {
                        case NODE_ID_LOCAL_ITEM:
                            {
                                //ulong L = (ulong)FindData.ftCreationTime.dwHighDateTime; L <<= 32; L |= (uint)FindData.ftCreationTime.dwLowDateTime;
                                FDCreate = ((INodeData_LOCAL_ITEM)NodeData).DCreate;// DateTime.FromFileTime((long)L);
                            } break;
                        case NODE_ID_GZIP_ITEM:
                        case NODE_ID_TAR_ITEM:
                        case NODE_ID_RAR_ITEM:
                        case NODE_ID_FTP_ITEM:
                        case NODE_ID_ZIP_ITEM:
                            {
                                FDCreate = DLastModify;
                            } break;
                    }
                }
                return FDCreate;
            }
        }
        /// <summary>Property: DLastModify</summary>
        public DateTime DLastModify
        {
            get
            {
                DateTime FDLastModify = DateTime.MinValue;
                if (FDLastModify == DateTime.MinValue)
                {
                    switch (ID)
                    {
                        case NODE_ID_VIRTUAL_ITEM:
                            {
                                FDLastModify = ((INodeData_VIRTUAL_ITEM)NodeData).DModify;
                            } break;
                        case NODE_ID_LOCAL_ITEM:
                            {
                                FDLastModify = ((INodeData_LOCAL_ITEM)NodeData).DModify; // DateTime.FromFileTime((long)L);
                            } break;
                        case NODE_ID_GZIP_ITEM:
                            {
                                if (((INodeData_GZIP_ITEM)NodeData).GZip_ModifyDate == 0) FDLastModify = DateTime.Now;
                                else FDLastModify = ICore.UnixTime2DateTime(((INodeData_GZIP_ITEM)NodeData).GZip_ModifyDate);
                            } break;
                        case NODE_ID_TAR_ITEM:
                            {
                                if (((INodeData_TAR_ITEM)NodeData).TAR_ModifyDate == 0) FDLastModify = DateTime.Now;
                                else FDLastModify = ICore.UnixTime2DateTime(((INodeData_TAR_ITEM)NodeData).TAR_ModifyDate);
                            } break;
                        case NODE_ID_RAR_ITEM:
                            {
                                if (((INodeData_RAR_ITEM)NodeData).RAR_ModifyDate == 0) FDLastModify = DateTime.Now;
                                else FDLastModify = ICore.MSDOSTime2DateTime(((INodeData_RAR_ITEM)NodeData).RAR_ModifyDate);
                            } break;
                        case NODE_ID_FTP_ITEM:
                            {
                                FDLastModify = ((INodeData_FTP_ITEM)NodeData).FTP_ModifyDate;
                            } break;
                        case NODE_ID_ZIP_ITEM:
                            {
                                FDLastModify = ((INodeData_ZIP)NodeData).ZIP_DModify;
                            } break;
                    }
                }
                return FDLastModify;
            }
        }
        /// <summary>Property: DLastAccess</summary>
        public DateTime DLastAccess
        {
            get
            {
                DateTime FDLastAccess = DateTime.MinValue;
                if (FDLastAccess == DateTime.MinValue)
                {
                    switch (ID)
                    {
                        case NODE_ID_LOCAL_ITEM:
                            {
                                //ulong L = (ulong)FindData.ftLastAccessTime.dwHighDateTime; L <<= 32; L |= (uint)FindData.ftLastAccessTime.dwLowDateTime;
                                FDLastAccess = ((INodeData_LOCAL_ITEM)NodeData).DLastAccess; // DateTime.FromFileTime((long)L);
                            } break;
                        case NODE_ID_GZIP_ITEM:
                        case NODE_ID_TAR_ITEM:
                        case NODE_ID_RAR_ITEM:
                        case NODE_ID_FTP_ITEM:
                        case NODE_ID_ZIP_ITEM:
                            {
                                FDLastAccess = DLastModify;
                            } break;
                    }
                }
                return FDLastAccess;
            }
        }
        /// <summary>Property: HasArchiveAttr</summary>
        public bool HasArchiveAttr
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_ARCHIVE) != 0;
                    default: return (Attributes & IWin32.FILE_ATTRIBUTE_ARCHIVE) != 0;
                }
            }
        }
        /// <summary>Property: HasCompressedAttr</summary>
        public bool HasCompressedAttr
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_COMPRESSED) != 0;
                    default: return (Attributes & IWin32.FILE_ATTRIBUTE_COMPRESSED) != 0;
                }
            }
        }
        /// <summary>Property: HasEncryptedAttr</summary>
        public bool HasEncryptedAttr
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_ENCRYPTED) != 0;
                    default: return (Attributes & IWin32.FILE_ATTRIBUTE_ENCRYPTED) != 0;
                }
            }
        }
        /// <summary>Property: HasHiddenAttr</summary>
        public bool HasHiddenAttr
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_HIDDEN) != 0;
                    default: return (Attributes & IWin32.FILE_ATTRIBUTE_HIDDEN) != 0;
                }
            }
        }
        /// <summary>Property: HasReadOnlyAttr</summary>
        public bool HasReadOnlyAttr
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_READONLY) != 0;
                    default: return (Attributes & IWin32.FILE_ATTRIBUTE_READONLY) != 0;
                }
            }
        }
        /// <summary>Property: HasSystemAttr</summary>
        public bool HasSystemAttr
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_LOCAL_ITEM: return (((INodeData_LOCAL_ITEM)NodeData).Attributes & IWin32.FILE_ATTRIBUTE_SYSTEM) != 0;
                    default: return (Attributes & IWin32.FILE_ATTRIBUTE_SYSTEM) != 0;
                }
            }
        }
        /// <summary>Property: UnixAttributes</summary>
        public uint UnixAttributes
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_TAR_ITEM: return ((INodeData_TAR_ITEM)NodeData).TAR_FileMode;
                    case NODE_ID_FTP_ITEM: return ((INodeData_FTP_ITEM)NodeData).FTP_Attributes;
                    default: return 0;
                }
            }
        }

        /// <summary>Property: KeyValue</summary>
        public string KeyValue
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_VIRTUAL_ITEM: return ((INodeData_VIRTUAL_ITEM)NodeData).OriginalPath.ToLower();
                    case NODE_ID_LOCAL_DRIVE: return ((INodeData_LOCAL_DRIVE)NodeData).DrvInfo.Name.ToLower();
                    case NODE_ID_LOCAL_ITEM: return ((INodeData_LOCAL_ITEM)NodeData).Name.ToLower();
                    case NODE_ID_SMB_ROOT: return "\\\\";
                    case NODE_ID_SMB_COMPUTER: return ((INodeData_SMB_COMPUTER)NodeData).ComputerName.ToLower();
                    case NODE_ID_SMB_SHARE: return ((INodeData_SMB_SHARE)NodeData).ShareNetName.ToLower();
                    case NODE_ID_GZIP_ITEM: return ((INodeData_GZIP_ITEM)NodeData).GZip_ItemName.ToLower();
                    case NODE_ID_TAR_ITEM: return ((INodeData_TAR_ITEM)NodeData).TAR_ItemName.ToLower();
                    case NODE_ID_RAR_ITEM: return ((INodeData_RAR_ITEM)NodeData).RAR_ItemName.ToLower();
                    case NODE_ID_CLOUD_DEVICES: return "web://";
                    case NODE_ID_FTP_CONNECTION: return ConnectionProvider.ToString() + "_" + ((INodeData_FTP_CONNECTION)NodeData).FTP_Conn_Name.ToLower();
                    case NODE_ID_FTP_ITEM: return ((INodeData_FTP_ITEM)NodeData).FTP_ItemName.ToLower();
                    case NODE_ID_ZIP_ITEM: return ((INodeData_ZIP)NodeData).ZIP_ItemName.ToLower();
                    default: return "";
                }
            }
        }
        /// <summary>Test ci node ma zadanu key. hodnotu</summary>
        /// <param name="pValue">hodnota na otestovanie</param>
        /// <returns>true / false</returns>
        public bool HasKeyValue(string pValue)
        {
            switch (ID)
            {
                case NODE_ID_VIRTUAL_ITEM: return string.Compare(((INodeData_VIRTUAL_ITEM)NodeData).OriginalPath, pValue, true) == 0;
                case NODE_ID_LOCAL_DRIVE: return string.Compare(((INodeData_LOCAL_DRIVE)NodeData).DrvInfo.Name, pValue, true) == 0;
                case NODE_ID_LOCAL_ITEM: return string.Compare(((INodeData_LOCAL_ITEM)NodeData).Name, pValue, true) == 0;
                case NODE_ID_SMB_ROOT: return pValue == "\\\\";
                case NODE_ID_SMB_COMPUTER: return string.Compare(((INodeData_SMB_COMPUTER)NodeData).ComputerName, pValue, true) == 0;
                case NODE_ID_SMB_SHARE: return string.Compare(((INodeData_SMB_SHARE)NodeData).ShareNetName, pValue, true) == 0;
                case NODE_ID_GZIP_ITEM: return string.Compare(((INodeData_GZIP_ITEM)NodeData).GZip_ItemName, pValue, true) == 0;
                case NODE_ID_TAR_ITEM: return string.Compare(((INodeData_TAR_ITEM)NodeData).TAR_ItemName, pValue, true) == 0;
                case NODE_ID_RAR_ITEM: return string.Compare(((INodeData_RAR_ITEM)NodeData).RAR_ItemName, pValue, true) == 0;
                case NODE_ID_CLOUD_DEVICES: return string.Compare(pValue, "web://", true) == 0;
                case NODE_ID_FTP_CONNECTION: return string.Compare(pValue, ConnectionProvider.ToString() + "_" + ((INodeData_FTP_CONNECTION)NodeData).FTP_Conn_Name, true) == 0;
                case NODE_ID_FTP_ITEM: return string.Compare(pValue, ((INodeData_FTP_ITEM)NodeData).FTP_ItemName, true) == 0;
                case NODE_ID_ZIP_ITEM: return string.Compare(pValue, ((INodeData_ZIP)NodeData).ZIP_ItemName, true) == 0;
                default: return false;
            }
        }
        /// <summary>Property: CloudName</summary>
        public string CloudName
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_FTP_CONNECTION: return ((INodeData_FTP_CONNECTION)NodeData).FTP_Conn_Name;
                    default: return "";
                }
            }
        }
        /// <summary>Property: CloudType</summary>
        public string CloudType
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_FTP_CONNECTION: return lang.NODE_LIST_CLOUD_DEVICES_TEXT_5_1;
                    default: return "";
                }
            }
        }
        /// <summary>Property: CloudCaption</summary>
        public string CloudCaption
        {
            get
            {
                switch (ID)
                {
                    case NODE_ID_FTP_CONNECTION: return ((INodeData_FTP_CONNECTION)NodeData).FTP_Conn_Caption;
                    default: return "";
                }
            }
        }

        /// <summary>Prevod atributov na retazec</summary>
        /// <param name="pAttr">hodnota</param>
        /// <returns>prevedeny vysledok</returns>
        public static string FormatAttributesAsString(uint pAttr, char pSeparator = ' ')
        {
            string Result = "";
            string Sep = pSeparator != 0 ? "-" + pSeparator.ToString() : "-";
            string Sep2 = pSeparator != 0 ? pSeparator.ToString() : "";
            Result += (pAttr & IWin32.FILE_ATTRIBUTE_ARCHIVE) != 0 ? "A" + Sep2 : Sep;
            Result += (pAttr & IWin32.FILE_ATTRIBUTE_COMPRESSED) != 0 ? "C" + Sep2 : Sep;
            Result += (pAttr & IWin32.FILE_ATTRIBUTE_ENCRYPTED) != 0 ? "E" + Sep2 : Sep;
            Result += (pAttr & IWin32.FILE_ATTRIBUTE_HIDDEN) != 0 ? "H" + Sep2 : Sep;
            Result += (pAttr & IWin32.FILE_ATTRIBUTE_READONLY) != 0 ? "R" + Sep2 : Sep;
            Result += (pAttr & IWin32.FILE_ATTRIBUTE_SYSTEM) != 0 ? "S" : "-";
            return Result;
        }
    }

    /// <summary>Trieda INodeData_ZIP</summary>
    public class INodeData_ZIP
    {
        public string ZIP_ItemName;
        public uint ZIP_Attributes;
        public long ZIP_OriginalSize;
        public long ZIP_CompressedSize;
        public DateTime ZIP_DModify;
        public uint ZIP_CRC;
        public string ZIP_Comment;
    }
    /// <summary>Trieda INodeData_FTP_ITEM</summary>
    public class INodeData_FTP_ITEM
    {
        public string FTP_ItemName;
        public long FTP_Size;
        public DateTime FTP_ModifyDate;
        public uint FTP_Attributes;
        public bool FTP_IsDirectory;
    }
    /// <summary>Trieda INodeData_FTP_CONNECTION</summary>
    public class INodeData_FTP_CONNECTION
    {
        public string FTP_Conn_Name;
        public string FTP_Conn_Caption;
        public string FTP_Conn_ServerName;
        public string FTP_Conn_LoginName;
        public string FTP_Conn_LoginPwd;
        public string FTP_Conn_RemoteFolder;
        public bool FTP_Conn_PassiveMode;
    }
    /// <summary>Trieda INodeData_RAR_ITEM</summary>
    public class INodeData_RAR_ITEM
    {
        public string RAR_ItemName;
        public long RAR_OriginalSize;
        public long RAR_CompressedSize;
        public uint RAR_CRC;
        public uint RAR_ModifyDate;
        public uint RAR_Attributes;
    }
    /// <summary>Trieda INodeData_TAR_ITEM</summary>
    public class INodeData_TAR_ITEM
    {
        public string TAR_ItemName;
        public uint TAR_FileMode;
        public string TAR_GroupID;
        public string TAR_UserID;
        public long TAR_OriginalSize;
        public uint TAR_ModifyDate;
        public bool TAR_IsDirectory;
        public long TAR_DataPosition;
    }
    /// <summary>Trieda INodeData_GZIP_ITEM</summary>
    public class INodeData_GZIP_ITEM
    {
        public string GZip_ItemName;
        public long GZip_OriginalSize;
        public long GZip_CompressedSize;
        public uint GZip_CRC;
        public uint GZip_ModifyDate;
        public byte GZip_OS;
    }
    /// <summary>Trieda INodeData_SMB_SHARE</summary>
    public class INodeData_SMB_SHARE
    {
        public string ShareNetName;
        public string SharePath;
        public IWin32.ShareType ShareType;
        public string ShareRemark;
    }
    /// <summary>Trieda INodeData_SMB_COMPUTER</summary>
    public class INodeData_SMB_COMPUTER
    {
        public string ComputerName;
        public string ComputerComment;
    }
    /// <summary>Trieda INodeData_LOCAL_DRIVE</summary>
    public class INodeData_LOCAL_DRIVE
    {
        public System.IO.DriveInfo DrvInfo;
    }
    /// <summary>Trieda INodeData_LOCAL_ITEM</summary>
    public class INodeData_LOCAL_ITEM
    {
        public uint Attributes;
        public DateTime DCreate;
        public DateTime DModify;
        public DateTime DLastAccess;
        public string Name;
        public ulong Size;
    }
    /// <summary>Trieda INodeData_LOCAL_ITEM</summary>
    public class INodeData_VIRTUAL_ITEM
    {
        public int OriginalID;
        public uint Attributes;
        public DateTime DModify;
        public string Name;
        public long Size;
        public string OriginalPath;
    }
}
